﻿using System;
using System.Collections.Generic;
using System.Web;
using MindTouch.Dream;
using MindTouch.Tasking;

namespace Morange.Async
{
    using Yield = IEnumerator<IYield>;

    /// <summary>
    /// Summary description for DreamAsyncHandler
    /// </summary>
    public abstract class DreamAsyncHandler : IHttpAsyncHandler, System.Web.SessionState.IRequiresSessionState
    {
        

        #region IHttpAsyncHandler Members

        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            return AsyncCore.AddAsyncPage(context, cb, Process, extraData);
        }

        public void EndProcessRequest(IAsyncResult result)
        {
            
        }

        #endregion

        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return false; }
        }

        public void ProcessRequest(HttpContext context)
        {
            throw new NotImplementedException();
        }

        #endregion

        public abstract Yield Process(AsyncCoreResult r, Result result);
    }
}

